<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>邮箱列表</h2>
    </div>

    <div class="tab-wrap with-padding">
        <ul class="nav nav-secondary">

            <li><a href="{:U('Admin/Addons/adminList',array('name'=>'Mail'))}">邮件配置</a></li>
            <li class="active"><a href="{:addons_url('Mail://Mail/mailList')}">邮箱列表</a></li>
            <li><a href="{:addons_url('Mail://Mail/sendEmail')}">发送邮件</a></li>
            <li><a href="{:addons_url('Mail://Mail/history')}">邮件历史</a></li>

        </ul>

        <div class="" style="padding-top: 5px;">
            <form action="{:addons_url('Mail://Mail/sendEmail')}" method="post">
                <div class="cf">
                    <a class="btn" href="{:addons_url('Mail://Mail/addEmail')}">新 增</a>
                    <button class="btn ajax-post btn" url="{:addons_url('Mail://Mail/delEmail')}" target-form="ids">删除
                    </button>
                    <button type="submit" class="btn">发送邮件</button>
                    <!-- 高级搜索 -->
                    <div class="search-form fr cf" style="padding-top: 10px;">


                        <div class="input-group" style="width: 400px;">
                            <input type="text" class="form-control search-input" placeholder="请输入邮箱地址" name="address"
                                   value="{:I('address')}">
            <span class="input-group-btn">
              <button class="btn btn-default" type="button" id="search" url="{:addons_url('Mail://Mail/mailList')}">搜索
              </button>
            </span>
                        </div>


                    </div>
                </div>

                <div class="data-table table-striped" style="margin-top: 10px">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th>
                                <input class="checkbox check-all" type="checkbox">
                            </th>
                            <th>ID</th>
                            <th>邮箱地址</th>

                        </tr>
                        </thead>
                        <tbody>
                        <notempty name="mailList">
                            <volist name="mailList" id="vo">
                                <tr>
                                    <td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$vo.id}">
                                    </td>
                                    <td>{$vo.id}</td>
                                    <td>{$vo.address}</td>
                                </tr>
                            </volist>
                            <else/>
                            <td colspan="6" class="text-center"> aOh! 暂时还没有内容!</td>
                        </notempty>
                        </tbody>
                    </table>

                </div>
            </form>
        </div>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        $(function () {
            //搜索功能
            $("#search").click(function () {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keypress(function (e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });

            $('input').keypress(function (e) {
                if (e.keyCode === 13) {
                    e.preventDefault()
                }
            })

        });
    </script>
</block>